1. Load Excel File and Add Header Row (10 points)

Load Library, Load Excel File, and Add Header Row

library(readxl)
Typical_Employee_Survey_Data <- read_excel('Typical_Employee_Survey_Data.xlsx', sheet='Survey', col_names = c("Age", "Gender", "Satisfaction", "Characteristics", "Years", "Promoted", "Empowerment", "Budgetary", "Proud", "Turndown", "Relations"))

Show Header Names

names(Typical_Employee_Survey_Data)
##  [1] "Age"             "Gender"          "Satisfaction"    "Characteristics"
##  [5] "Years"           "Promoted"        "Empowerment"     "Budgetary"      
##  [9] "Proud"           "Turndown"        "Relations"

Show Beginning of File

head(Typical_Employee_Survey_Data)
## # A tibble: 6 × 11
##     Age Gender Satisfaction Characteristics Years Promoted Empowerment Budgetary
##   <dbl>  <dbl>        <dbl>           <dbl> <dbl>    <dbl>       <dbl>     <dbl>
## 1    35      1            2               4   3          1           2         1
## 2    33      1            2               3   9          5           2         1
## 3    23      1            1               1   1.5        1           2         2
## 4    60      1            1               1  20          3           2         2
## 5    35      1            2               1   3          3           2         1
## 6    34      2            2               1   6          1           2         2
## # ℹ 3 more variables: Proud <dbl>, Turndown <dbl>, Relations <dbl>

Show End of File

tail(Typical_Employee_Survey_Data)
## # A tibble: 6 × 11
##     Age Gender Satisfaction Characteristics Years Promoted Empowerment Budgetary
##   <dbl>  <dbl>        <dbl>           <dbl> <dbl>    <dbl>       <dbl>     <dbl>
## 1    49      1            2               4  1.5         5           4         1
## 2    35      2            2               2 10           4           3         2
## 3    22      1            1               5  1           1           1         2
## 4    33      2            1               5 11           5           2         1
## 5    29      2            1               5  2           2           2         1
## 6    22      1            2               2  1.25        1           2         2
## # ℹ 3 more variables: Proud <dbl>, Turndown <dbl>, Relations <dbl>

3. Convert the columns that need to be converted to Factors (10 points)

Gender Column

Typical_Employee_Survey_Data$Gender <- as.factor(Typical_Employee_Survey_Data$Gender)
class(Typical_Employee_Survey_Data$Gender)
## [1] "factor"

Satisfaction Column

Typical_Employee_Survey_Data$Satisfaction <- as.factor(Typical_Employee_Survey_Data$Satisfaction)
class(Typical_Employee_Survey_Data$Satisfaction)
## [1] "factor"

Characteristics Column

Typical_Employee_Survey_Data$Characteristics <- as.factor(Typical_Employee_Survey_Data$Characteristics)
class(Typical_Employee_Survey_Data$Characteristics)
## [1] "factor"

Empowerment Column

Typical_Employee_Survey_Data$Empowerment <- as.factor(Typical_Employee_Survey_Data$Empowerment)
class(Typical_Employee_Survey_Data$Empowerment)
## [1] "factor"

Budgetary Column

Typical_Employee_Survey_Data$Budgetary <- as.factor(Typical_Employee_Survey_Data$Budgetary)
class(Typical_Employee_Survey_Data$Budgetary)
## [1] "factor"

Proud Column

Typical_Employee_Survey_Data$Proud <- as.factor(Typical_Employee_Survey_Data$Proud)
class(Typical_Employee_Survey_Data$Proud)
## [1] "factor"

Turndown Column

Typical_Employee_Survey_Data$Turndown <- as.factor(Typical_Employee_Survey_Data$Turndown)
class(Typical_Employee_Survey_Data$Turndown)
## [1] "factor"

Relations Column

Typical_Employee_Survey_Data$Relations <- as.factor(Typical_Employee_Survey_Data$Relations)
class(Typical_Employee_Survey_Data$Relations)
## [1] "factor"

4. Plot the right visual for each column (20 points)

Age Histogram

Histogram is the Right Visual!

hist(Typical_Employee_Survey_Data$Age, main="Histogram of Age vs People", col="Blue", xlab="Age", ylab="Number of People")

barplot(Typical_Employee_Survey_Data$Age, main="Bar Plot of Age", col="Red")

Gender Plots

Pie Chart is the Right Visual!

plot(Typical_Employee_Survey_Data$Gender, col="Blue", main="Plot of Gender vs People", xlab="Gender (1=male, 2=female)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Gender, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Gender vs Age", xlab="Gender (1=male, 2=female)", ylab="Age")

pie(table(Typical_Employee_Survey_Data$Gender), main="Pie Chart of Gender", xlab="Gender (1=male, 2=female)", labels = c("male", "female"))

Satisfaction Plots

Pie Chart is the Right Visual!

plot(Typical_Employee_Survey_Data$Satisfaction, col="Blue", main="Plot of People vs Satisfaction", xlab="Satisfaction (1=very satisfied, 4=very dissatisfied)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Satisfaction, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Satisfaction", xlab="Satisfaction (1=very satisfied, 4=very dissatisfied)", ylab="Age")

pie(table(Typical_Employee_Survey_Data$Satisfaction), main="Pie Chart of Satisfaction", xlab="Satisfaction (1=very satisfied, 4=very dissatisfied)", labels = c("very satisfied", "moderately satisfied", "a little dissatisfied", "very dissatisfied"))

Characteristics Plots

Bar Chart is the Right Visual!
plot(Typical_Employee_Survey_Data$Characteristics, col="Blue", main="Plot of People vs Characteristics", xlab="Characteristics", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Characteristics, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Characteristics", xlab="Characteristics", ylab="Age")

Years Histogram

Histogram is the Right Visual!

hist(Typical_Employee_Survey_Data$Years, main="Histogram of People vs Years", col="Blue", xlab="Years", ylab="Number of People")

barplot(Typical_Employee_Survey_Data$Years, main="Bar Plot of Years", col="Blue")

Empowerment Plots

Bar Chart is the Right Visual!
plot(Typical_Employee_Survey_Data$Empowerment, col="Blue", main="Plot of People vs Empowerment", xlab="Empowerment (1=always, 4=never)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Empowerment, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Empowerment", xlab="Empowerment (1=always, 4=never)", ylab="Age")

Budgetary Plots

Pie Chart is the Right Visual!

plot(Typical_Employee_Survey_Data$Budgetary, col="Blue", main="Plot of People vs Budgetary", xlab="Budgetary (1=yes, 2=no)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Budgetary, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Budgetary", xlab="Budgetary (1=yes, 2=no)", ylab="Age")

pie(table(Typical_Employee_Survey_Data$Budgetary), main="Pie Chart of Budgetary Decisions", xlab="Budget (1=Yes, 2=No)", labels = c("Yes", "No"))

Proud Plots

Pie Chart is the Right Visual!

plot(Typical_Employee_Survey_Data$Proud, col="Blue", main="Plot of People vs Proud", xlab="Proud (1=very proud, 4=not at all proud)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Proud, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Proud", xlab="Proud (1=very proud, 4=not at all proud)", ylab="Age")

pie(table(Typical_Employee_Survey_Data$Proud), main="Pie Chart of Proud", xlab="Proud (1=very proud, 4=not at all proud)", labels = c("very proud", "somewhat proud", "indifferent", "not at all proud"))

Turndown Plots

Bar Chart is the Right Visual!
plot(Typical_Employee_Survey_Data$Turndown, col="Blue", main="Plot of People vs Turndown", xlab="Turndown (1=very likely, 5=very unlikely)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Turndown, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Turndown", xlab="Turndown (1=very likely, 5=very unlikely)", ylab="Age")

Relations Plots

Bar Chart is the Right Visual!
plot(Typical_Employee_Survey_Data$Relations, col="Blue", main="Plot of People vs Relations", xlab="Relations (1=very good, 5=very bad)", ylab="Number of People")

plot(Typical_Employee_Survey_Data$Relations, Typical_Employee_Survey_Data$Age, col="Red", main="Plot of Age vs Relations", xlab="Relations (1=very good, 5=very bad)", ylab="Age")

5. Plot scatter plots to show few relationships (20 points)

Years vs Age Scatter Plot

plot(Typical_Employee_Survey_Data$Age, Typical_Employee_Survey_Data$Years, main="Scatter Plot of Years vs Age", col="Red", xlab="Age", ylab="Years of Service")

Gender vs Years Scatter Plot

plot(Typical_Employee_Survey_Data$Years, Typical_Employee_Survey_Data$Gender, main="Scatter Plot of Gender vs Years", col="Blue", xlab="Years of Service", ylab="Gender (1=male, 2=female)")

Gender vs Age Scatter Plot

plot(Typical_Employee_Survey_Data$Age, Typical_Employee_Survey_Data$Gender, main="Scatter Plot of Gender vs Age", col="Red", xlab="Age", ylab="Gender (1=male, 2=female)")

Satisfaction vs Age Scatter Plot

plot(Typical_Employee_Survey_Data$Age, Typical_Employee_Survey_Data$Satisfaction, main="Scatter Plot of Satisfaction vs Age", col="Blue", xlab="Age", ylab="Satisfaction (1=very satisfied, 4=very dissatisfied)")

Satisfaction vs Turndown Scatter Plot

plot(as.numeric(Typical_Employee_Survey_Data$Turndown), as.numeric(Typical_Employee_Survey_Data$Satisfaction), main="Scatter Plot of Satisfaction vs Turndown", col="Brown", xlab="Turndown (1=very likely, 5=very unlikely)", ylab="Satisfaction (1=very satisfied, 4=very dissatisfied)")

Satisfaction vs Years Scatter Plot

plot(Typical_Employee_Survey_Data$Years, Typical_Employee_Survey_Data$Satisfaction, main="Scatter Plot of Satisfaction vs Years", col="Blue", xlab="Years", ylab="Satisfaction (1=very satisfied, 4=very dissatisfied)")

Turndown vs Age Scatter Plot

plot(Typical_Employee_Survey_Data$Age, Typical_Employee_Survey_Data$Turndown, main="Scatter Plot of Turndown vs Age", col="Red", xlab="Age", ylab="Turndown (1=very likely, 5=very unlikely)")

Satisfaction and Gender vs Age Scatter Plot

plot(Typical_Employee_Survey_Data$Age, as.numeric(Typical_Employee_Survey_Data$Satisfaction), main="Scatter Plot of Gender and Satisfaction vs Age", col="Red", xlab="Age", ylab="Gender (Blue), Satisfaction (Red)")
points(Typical_Employee_Survey_Data$Age, as.numeric(Typical_Employee_Survey_Data$Gender), col="Blue")

Gender and Proud vs Age Scatter Plot

plot(Typical_Employee_Survey_Data$Age, as.numeric(Typical_Employee_Survey_Data$Proud), main="Scatter Plot of Gender and Proud vs Age", col="Red", xlab="Age", ylab="Gender (Blue), Proud (Red)")
points(Typical_Employee_Survey_Data$Age, as.numeric(Typical_Employee_Survey_Data$Gender), col="Blue")

Years vs People Scatter Plot

plot(Typical_Employee_Survey_Data$Years, main="Scatter Plot of Years vs People", col="Red", xlab="People (rows)", ylab="Years of Service")

Age vs People Scatter Plot

plot(Typical_Employee_Survey_Data$Age, main="Scatter Plot of Age vs People", col="Blue", xlab="People (rows)", ylab="Age")